package com.ljx.offer;

/**
 * @author 李捷禧
 * Date: 2023/3/28
 * ClassName: C_63
 */

public class C_63 {
    /**
     * 股票的最大利润
     * @param prices
     * @return
     */
    public int maxProfit(int[] prices) {
        int min = Integer.MAX_VALUE;
        int max = 0;
        for (int i = 0; i < prices.length; i++) {
            min = Math.min(min,prices[i]);
            max = Math.max(max,prices[i] -min);
        }
        return max;
    }

}
